package huawei.test;

import java.util.*;
import java.util.stream.Collectors;

public class ArrDistinctSorted {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = Arrays.stream(sc.nextLine().split(","))
                .mapToInt(Integer::parseInt)
                .toArray();
        Map<Integer, Integer> frequenceMap = new LinkedHashMap<>(arr.length);
        for (int e: arr) {
            frequenceMap.put(e,frequenceMap.getOrDefault(e,0)+1);
        }
        String result = frequenceMap.entrySet()
                .stream()
                .sorted((o1, o2) -> {
                    Integer value1 = o1.getValue();
                    Integer value2 = o2.getValue();
                    if (!value1.equals(value2)) {
                        return value2 - value1;
                    }
                    return 0;
                })
                .map(Map.Entry::getKey)
                .map(Objects::toString)
                .collect(Collectors.joining(","));
        System.out.println(result);
    }
}
